<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        body {
            background-image: url(img/login1.jpg);
            background-size: 100% 660px;
        }

        input {
            outline: none;
            border: 1px solid rgb(150, 148, 148);
            border-radius: 10px;
        }

        button {
            outline: none;
        }

        a {
            text-decoration: none;
        }

        .container {
            position: relative;
            margin: 100px auto;
            width: 400px;
            height: 520px;
            border: 1px solid rgb(163, 151, 151);
            border-radius: 10px;
            overflow: hidden;
            background-color: #fff;
            padding: 0;
        }


        .top_user {
            width: 100%;
            height: 50px;
            line-height: 50px;
            background-color: rgb(56, 78, 136);
            font-size: 18px;
            font-weight: 600;
            float: left;
            cursor: pointer;
            color: white;
            padding-left: 10px;
        }

        .form-group {
            position: relative;
            margin-left: 10px;
        }


        .form-group label {
            display: block;
            position: relative;
            left: 0px;
            font-size: 16px;
            color: black;
            margin-bottom: -10px;
        }

        .form-control {
            width: 350px;
            height: 35px;
            position: relative;
            margin: 0;
            /* margin-top: -10px; */
        }

        .btn {
            position: relative;
            top: 0px;
            left: 0px;
            width: 100px;
            height: 35px;
            cursor: pointer;
            color: white;
            font-size: 16px;
            outline: none;
            border-radius: 5px;
            background-color: rgb(36, 115, 180);
        }

        .btn:focus {
            outline: none;
            color: white;
            border: 0 none;
        }
    </style>
</head>

<body>
    <div class="container" id="app">
        <div class="top_user">商品后台管理
            <div class="form-group">
                <label>编号: {{id}} </label>
                <label>名称:</label>
                <input type="text" class="form-control" v-model="goodname">
                <label>租价:</label>
                <input type="text" class="form-control" v-model="goodprice">
                <label>售价:</label>
                <input type="text" class="form-control" v-model="goodsell">
                <label>库存:</label>
                <input type="text" class="form-control" v-model="stock">
                <button class="btn" @click="submit">提交</button>
            </div>
        </div>
    </div>
</body>
<script src="js/vue.js"></script>
<script src="js/vue-resource.min.js"></script>
<script>
    var vm = new Vue({
        el: '#app',
        data: {
            id: '',
            goodname: '',
            goodprice: '',
            goodsell: '',
            stock: ''
        },
        methods: {
            getMes: function () {
                this.id = JSON.parse(localStorage.getItem('id'));
                this.goodname = JSON.parse(localStorage.getItem('goodname'));
                this.goodprice = JSON.parse(localStorage.getItem('goodprice'));
                this.goodsell = JSON.parse(localStorage.getItem('goodsell'));
                this.stock = JSON.parse(localStorage.getItem('stock'));
            },
            submit: function () {
                this.$http.post('php/submit.php', {
                        id: this.id,
                        goodname: this.goodname,
                        goodprice: this.goodprice,
                        goodsell: this.goodsell,
                        stock: this.stock,
                    }, {
                        emulateJSON: true
                    })
                    .then(function (result) {
                        if (result.body.code == 0) {
                            alert('修改成功!!2s后跳转至后台管理页面');
                            setTimeout(function () {
                                location.href = "admin_main.html";
                            }, 2000);
                        } else {
                            alert(result.body.message)
                        }
                    })
            }
        },
        created() {
            this.getMes();
        }
    })
</script>

</html>